//
//  MainHomePageSchemaView.swift
//  FrameProduct
//
//  Created by delegate on 2025/10/20.
//

import UIKit

class MainHomePageSchemaView: UIView {
    var schemaButtonActionBlock: (() -> Void)?
    var autoPrivacyButtonActionBlock: (() -> Void)?
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    private func setupUI() {
        addSubviews(bgImageView)
        bgImageView.addSubviews(centerLineView, autoPrivacyButton, schemaButton)
        bgImageView.snp.makeConstraints { make in
            make.left.equalTo(67)
            make.right.equalTo(-67)
            make.top.equalToSuperview()
            make.height.equalTo(46)
            make.bottom.equalToSuperview()
        }
        centerLineView.snp.makeConstraints { make in
            make.centerX.centerY.equalToSuperview()
            make.width.equalTo(1)
            make.height.equalTo(15)
        }
        schemaButton.snp.makeConstraints { make in
            make.left.equalToSuperview()
            make.top.equalToSuperview()
            make.bottom.equalToSuperview()
            make.right.equalTo(centerLineView.snp.left)
        }
        autoPrivacyButton.snp.makeConstraints { make in
            make.left.equalTo(centerLineView.snp.right)
            make.right.equalToSuperview()
            make.top.equalToSuperview()
            make.bottom.equalToSuperview()
            
        }
    }
    @objc private func schemaButtonAction() {
        schemaButtonActionBlock?()
    }
    @objc private func autoPrivacyButtonAction() {
        autoPrivacyButtonActionBlock?()
    }
    //=================================================================
    //                            lazy
    //=================================================================
    // MARK: - lazy
    private lazy var bgImageView: UIImageView = {
        let imageView = UIImageView(frame: .zero)
        imageView.image = UIImage(named: "home_moshi_bg_img")
        imageView.isUserInteractionEnabled = true
        return imageView
    }()
    private lazy var centerLineView: UIView = {
        let lineView = UIView()
        lineView.backgroundColor = .lxs.hex("#E5E5E5")
        return lineView
    }()
    private lazy var schemaButton: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitle("全局模式", for: .normal)
        button.setTitle("全局模式", for: .selected)
        button.setTitleColor(.lxs.hex("#BFE0FF"), for: .normal)
        button.setTitleColor(.lxs.hex("#BFE0FF"), for: .selected)
        button.titleLabel?.font = .lxs.font(size: 12)
        button.addTarget(self, action: #selector(schemaButtonAction), for: .touchUpInside)
        return button
    }()
    private lazy var autoPrivacyButton: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitle("自动协议", for: .normal)
        button.setTitle("自动协议", for: .selected)
        button.setTitleColor(.lxs.hex("#BFE0FF"), for: .normal)
        button.setTitleColor(.lxs.hex("#BFE0FF"), for: .selected)
        button.titleLabel?.font = .lxs.font(size: 12)
        button.addTarget(self, action: #selector(autoPrivacyButtonAction), for: .touchUpInside)
        return button
    }()
}
